package luj.tool.jnproxyan.proxy.network.socks.actor.root;

import com.jcraft.jsch.Session;
import io.netty.channel.EventLoopGroup;
import luj.cluster.api.actor.ActorMessageHandler;
import luj.data.api.Data;
import luj.net.api.client.ConnectionFactory;
import luj.tool.jnproxyan.proxy.database.DatabaseState;
import luj.tool.jnproxyan.proxy.stats.http.history.state.HttpHistoryDat;
import luj.tool.jnproxyan.proxy.network.socks.request.SocksRequest;

import java.util.HashMap;
import java.util.Map;

public class Socks5Actor {

  public interface Handler<M> extends ActorMessageHandler<Socks5Actor, M> {
    // NOOP
  }

  public Socks5Actor(Data connectRule, EventLoopGroup connectLoop, ConnectionFactory connectionFactory, Session sshSession, DatabaseState databaseState) {
    _connectRule = connectRule;
    _connectLoop = connectLoop;
    _connectionFactory = connectionFactory;
    _sshSession = sshSession;
    _databaseState = databaseState;
  }

  public Map<Long, SocksRequest> getRequestMap() {
    return _requestMap;
  }

  @Deprecated
  public Data getConnectRule() {
    return _connectRule;
  }

  public EventLoopGroup getConnectLoop() {
    return _connectLoop;
  }

  public ConnectionFactory getConnectionFactory() {
    return _connectionFactory;
  }

  public Session getSshSession() {
    return _sshSession;
  }

  public DatabaseState getDatabaseState() {
    return _databaseState;
  }

  public HttpHistoryDat getHttpHistoryDat() {
    return _httpHistoryDat;
  }

  private final Map<Long, SocksRequest> _requestMap = new HashMap<>();

  private final EventLoopGroup _connectLoop;
  private final ConnectionFactory _connectionFactory;
  private final Session _sshSession;

  private final DatabaseState _databaseState;
  private final HttpHistoryDat _httpHistoryDat = new HttpHistoryDat();

  @Deprecated
  private final Data _connectRule;
}
